<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
   String sid= request.getParameter("sid");
%>
<html>
<head>
    <title>Title</title>
    <script language="JavaScript" src="${pageContext.request.contextPath}/Js/jquery-1.7.2.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/Admin.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/bootstrap.min.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/Js/question/question.js"></script>

        <script language="JavaScript" src="../Js/Func.js"></script>

       <script language="javascript">window.onload=tableFix</script>
    <script type="text/javascript">
        function showType(typecode) {
            //typecode: dx--单选 ;fx--复选;
            document.getElementById("qEditor").innerHTML = document.getElementById(typecode).innerHTML;
        }

        function setJD(qid) {
            var sUrl = setQueryString("op", "setJD", "QuestionJD.jsp");
            sUrl = setQueryString("sid", "<%=request.getParameter("sid")%>", sUrl);
            window.location = setQueryString("qid", qid, sUrl);
        }

        function setTZ(qid) {
            var sUrl = setQueryString("op", "setTZ", "QuestionTZ.jsp");
            sUrl = setQueryString("sid", "<%=request.getParameter("sid")%>", sUrl);
            window.location = setQueryString("qid", qid, sUrl);
        }

        function test1() {
            var postData = "sid=" + $.trim($("#sid").val()) +
                "&qsHead=" + $.trim($("#qsHead").val()) +
                "&answer1=" + $.trim($("#answer1").val())+
                "&answer2=" + $.trim($("#answer2").val())+
                "&answer3=" + $.trim($("#answer3").val())+
                "&answer4=" + $.trim($("#answer4").val())+
                    "&type=1"
            ;
            //alert(postData);
            $.post("/admin/question/addQuestion", postData, function (data) {
                if (data.code == 200) {
                    alert("添加成功");
                    window.location.href="${pageContext.request.contextPath}/admin/question/questionManage?sid="+<%=sid%>;
                } else {
                    alert("添加失败");
                }
            }, 'json');
        }


        function test2() {
            var postData = "sid=" + $.trim($("#sid").val()) +
                "&qsHead=" + $.trim($("#qmHead").val()) +
                "&answer1=" + $.trim($("#answerm1").val())+
                "&answer2=" + $.trim($("#answerm2").val())+
                "&answer3=" + $.trim($("#answerm3").val())+
                "&answer4=" + $.trim($("#answerm4").val())+
                "&type=2"
            ;
            //alert(postData);
            $.post("/admin/question/addQuestion", postData, function (data) {
                if (data.code == 200) {
                    alert("添加成功");
                    window.location.href="${pageContext.request.contextPath}/admin/question/questionManage?sid="+<%=sid%>;
                } else {
                    alert("添加失败");
                }
            }, 'json');
        }

    </script>
</head>
<body>
<div class=nav><a href=admin_main.jsp>桌面</a>»管理员添加
</div>
<div id="admin_surveyAdd_main">
    <table class=table cellspacing="0" cellpadding="0">
        <tr>
            <th>添加新题目</th>
            <th></th>
            <th></th>
        </tr>
        <tr>
            <td>选择题型：</td>
            <td>
                <input name="Question_type" id="qtype_dx" type="radio" value="1" onClick="showType('dx');">单选题
                <input name="Question_type" type="radio" value="2" onClick="showType('fx');">多选题
            </td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
    <div id=qEditor></div>
    <div id=dx style="display:none">
        <form name="form1">
            <input type="hidden" value="<%=sid%>" name="sid" id="sid">
            <input type="hidden" value="" name="qBody" id="qBody1">
            <input type="hidden" value="" name=qResult id="qResult1">
            问题：<input name="qHead" id="qsHead" type="text" size="40">
            <br/><br/>
            备选项：
            <ul type="1" id="ulAnswer1">
                <li><input type="radio"><input type="text" name="Answer" id="answer1"></li>
                <li><input type="radio"><input type="text" name="Answer" id="answer2"></li>
                <li><input type="radio"><input type="text" name="Answer" id="answer3"></li>
                <li><input type="radio"><input type="text" name="Answer" id="answer4"></li>
            </ul>
            <div id="button1">
                <input type="button" id="sinButton" value="添加题目" onclick="test1()"/>
            </div>
        </form>
    </div>
    <div id=fx style="display: none">
        <form name="form1">
            <input type="hidden" value=<%=request.getParameter("sid") %>  name="sid">
            <input type="hidden" value="" name="qBody" id="qBody">
            <input type="hidden" value="" name=qResult id="qResult">
            问题：<input name="qHead" id="qmHead" type="text" size="40">
            <br/><br/>
            备选项：
            <ul type="1" id="ulAnswer">
                <li><input type="checkbox"><input type="text" name="Answer" id="answerm1"></li>
                <li><input type="checkbox"><input type="text" name="Answer" id="answerm2"></li>
                <li><input type="checkbox"><input type="text" name="Answer" id="answerm3"></li>
                <li><input type="checkbox"><input type="text" name="Answer" id="answerm4"></li>
            </ul>
            <div id="button">
                <input type="button" id="mutButton" value="添加题目" onclick="test2()">
            </div>
        </form>
    </div>

</div>
<script type="text/javascript">
    /*  document.getElementById("qtype_dx").click();*/
</script>
<%--<script type="text/javascript">
    $(function () {
        $("#sinButton").click(function () {
            alert("sda");

           /* var postData="sid="+$.trim($(".sid").val())+
                "&qsHead="+$.trim($("#qsHead").val())+
                "&answer="+$.trim($(".Answer").val());
            alert(postData);*/
            /*$.post("/link/addLink",postData,function (data) {
                if(data.code == 200){
                    alert("添加成功");
                    window.location.href = "/admin/FriendLinkAdmin.jsp";
                }else {
                    alert("添加失败");
                }
            },'json');*/
        });
    });

</script>--%>
</body>
</html>
